package com.zjcloud.jwgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.jwgl.domain.AcSchoolInfo;
import com.zjcloud.jwgl.service.IAcSchoolInfoService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 学校基础信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-08
 */
@RestController
@RequestMapping("/jwgl/schoolinfo")
public class AcSchoolInfoController extends BaseController
{
    @Autowired
    private IAcSchoolInfoService acSchoolInfoService;

    /**
     * 查询学校基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('jwgl:schoolinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(AcSchoolInfo acSchoolInfo)
    {
        startPage();
        List<AcSchoolInfo> list = acSchoolInfoService.selectAcSchoolInfoList(acSchoolInfo);
        return getDataTable(list);
    }

    /**
     * 导出学校基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('jwgl:schoolinfo:export')")
    @Log(title = "学校基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AcSchoolInfo acSchoolInfo)
    {
        List<AcSchoolInfo> list = acSchoolInfoService.selectAcSchoolInfoList(acSchoolInfo);
        ExcelUtil<AcSchoolInfo> util = new ExcelUtil<AcSchoolInfo>(AcSchoolInfo.class);
        util.exportExcel(response, list, "学校基础信息数据");
    }

    /**
     * 获取学校基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('jwgl:schoolinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(acSchoolInfoService.selectAcSchoolInfoById(id));
    }

    /**
     * 新增学校基础信息
     */
    @PreAuthorize("@ss.hasPermi('jwgl:schoolinfo:add')")
    @Log(title = "学校基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AcSchoolInfo acSchoolInfo)
    {
        return toAjax(acSchoolInfoService.insertAcSchoolInfo(acSchoolInfo));
    }

    /**
     * 修改学校基础信息
     */
    @PreAuthorize("@ss.hasPermi('jwgl:schoolinfo:edit')")
    @Log(title = "学校基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AcSchoolInfo acSchoolInfo)
    {
        return toAjax(acSchoolInfoService.updateAcSchoolInfo(acSchoolInfo));
    }

    /**
     * 删除学校基础信息
     */
    @PreAuthorize("@ss.hasPermi('jwgl:schoolinfo:remove')")
    @Log(title = "学校基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(acSchoolInfoService.deleteAcSchoolInfoByIds(ids));
    }
}
